/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author QUY_THI
 */
@Entity
@Table(name = "Withdrawals")
@NamedQueries({
    @NamedQuery(name = "Withdrawal.findAll", query = "SELECT w FROM Withdrawal w"),
    @NamedQuery(name = "Withdrawal.findByWithdrawalID", query = "SELECT w FROM Withdrawal w WHERE w.withdrawalID = :withdrawalID"),
    @NamedQuery(name = "Withdrawal.findByAmount", query = "SELECT w FROM Withdrawal w WHERE w.amount = :amount"),
    @NamedQuery(name = "Withdrawal.findByWithdrawalDate", query = "SELECT w FROM Withdrawal w WHERE w.withdrawalDate = :withdrawalDate")})
public class Withdrawal implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name = "WithdrawalID")
    private Integer withdrawalID;
    @Basic(optional = false)
    @Column(name = "Amount")
    private BigDecimal amount;
    @Column(name = "WithdrawalDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date withdrawalDate;
    @JoinColumn(name = "AccountCode", referencedColumnName = "AcountCode")
    @ManyToOne
    private Account account;

    public Withdrawal() {
    }

    public Withdrawal(Integer withdrawalID) {
        this.withdrawalID = withdrawalID;
    }

    public Withdrawal(Integer withdrawalID, BigDecimal amount) {
        this.withdrawalID = withdrawalID;
        this.amount = amount;
    }

    public Integer getWithdrawalID() {
        return withdrawalID;
    }

    public void setWithdrawalID(Integer withdrawalID) {
        this.withdrawalID = withdrawalID;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public Date getWithdrawalDate() {
        return withdrawalDate;
    }

    public void setWithdrawalDate(Date withdrawalDate) {
        this.withdrawalDate = withdrawalDate;
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (withdrawalID != null ? withdrawalID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Withdrawal)) {
            return false;
        }
        Withdrawal other = (Withdrawal) object;
        if ((this.withdrawalID == null && other.withdrawalID != null) || (this.withdrawalID != null && !this.withdrawalID.equals(other.withdrawalID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Withdrawal[withdrawalID=" + withdrawalID + "]";
    }

}
